Upgrade VM, crypto, and rand dependencies#3146
Conversation
| @@ -1 +1,4 @@ | |||
| #![cfg_attr(not(feature = "concurrent"), no_std)] | |||
There was a problem hiding this comment.
Do we need to run benchmarks for no_std or why is this needed? I assume this has something to do with all dependencies being made optional as well?
There was a problem hiding this comment.
The issue is Cargo feature unification. The transaction benchmark uses the concurrent proving path. Since 0xMiden/crypto#1073, miden-lifted-stark/concurrent is part of the default crypto stack. In crypto 0.27, miden-crypto/concurrent enables std. On the protocol side, miden-tx/concurrent and miden-processor/concurrent also require std.
That works for the benchmark, but it must not leak into cargo build --no-default-features --target wasm32-unknown-unknown --workspace --lib. So the feature gate keeps normal benchmark builds as the default through default = ["concurrent"], while the no-default library build does not enable the std only benchmark stack.
There was a problem hiding this comment.
It seems like a large part of the changes are related to packages and the way we assemble MASM. Does this not result in many conflicts with #2896? That workstream currently has 4 open PRs. So it seems it would make sense to do this migration after that issue was resolved, wdyt?
There was a problem hiding this comment.
Yes, this PR is already doing part of issue #2896. The VM 0.24 upgrade removes the old shape of several Library and Program APIs, so this PR has to move some code to Package and MastForest. That is visible in account component code, note scripts, transaction scripts, and the build scripts.
The part this PR does not do is the project file migration. It adds no miden-project.toml files, and it does not move protocol or standards assembly to the declarative project layout from #3094 and #3107.
I think this leaves us with an ordering choice. If we want the dependency upgrade now, this PR can land first and the project file PRs can rebase over it. If we want less churn in the package migration work, this PR can wait and I can rebase it after #3094 and #3107.
There was a problem hiding this comment.
Looking through this PR, I think I agree with @bitwalker that it would be better to mere #3094 and #3107 first.
This could work well with timing as I think @huitseeker you are out tomorrow (Wednesday).
ce78962 to
f09c095
Compare
There was a problem hiding this comment.
Looks good! Really like the new import syntax. There are still many places where the imports can be consolidated. I opened an issue in the VM for adding unused import checking. I think the new import syntax makes it easier to have unused imports.
For the most part looks good so far, I didn't get through everything just yet, will re-review in 24-48h, or feel free to re-request my review if you address things sooner.
| @@ -1,4 +1,4 @@ | |||
| use agglayer::bridge::bridge_in -> bridge | |||
| use agglayer::bridge::bridge_in as bridge | |||
| pub use { | ||
| FUNGIBLE_ASSET_MAX_AMOUNT, | ||
| ASSET_SIZE, | ||
| ASSET_VALUE_MEMORY_OFFSET, |
| use { | ||
| ACCOUNT_GET_ID_OFFSET, | ||
| ACCOUNT_GET_NONCE_OFFSET, | ||
| ACCOUNT_GET_INITIAL_COMMITMENT_OFFSET, | ||
| ACCOUNT_COMPUTE_COMMITMENT_OFFSET, | ||
| ACCOUNT_GET_CODE_COMMITMENT_OFFSET, | ||
| ACCOUNT_GET_INITIAL_STORAGE_COMMITMENT_OFFSET, | ||
| ACCOUNT_COMPUTE_STORAGE_COMMITMENT_OFFSET, | ||
| ACCOUNT_GET_INITIAL_VAULT_ROOT_OFFSET, | ||
| ACCOUNT_GET_VAULT_ROOT_OFFSET, | ||
| ACCOUNT_GET_ITEM_OFFSET, | ||
| ACCOUNT_HAS_STORAGE_SLOT_OFFSET, | ||
| ACCOUNT_GET_INITIAL_ITEM_OFFSET, | ||
| ACCOUNT_GET_MAP_ITEM_OFFSET, | ||
| ACCOUNT_GET_INITIAL_MAP_ITEM_OFFSET, | ||
| ACCOUNT_GET_ASSET_OFFSET, | ||
| ACCOUNT_GET_INITIAL_ASSET_OFFSET, | ||
| ACCOUNT_GET_NUM_PROCEDURES_OFFSET, | ||
| ACCOUNT_GET_PROCEDURE_ROOT_OFFSET, | ||
| ACCOUNT_HAS_PROCEDURE_OFFSET, | ||
| } from miden::protocol::kernel_proc_offsets |
There was a problem hiding this comment.
When experimenting with this branch locally, I noticed its easy to add imports with this new import syntax, and not actually use the imported procedure or const. I opened an issue in the VM to discuss.
There was a problem hiding this comment.
Yeah that is a bug if those aren't being used anywhere - we do have unused import checking implemented, but it may be buggy still.
There was a problem hiding this comment.
For the record the imports being commented on in this comment are used.
a2502cf to
b2a6275
Compare
bitwalker
left a comment
There was a problem hiding this comment.
I only looked over the assembly-related bits, but looks good to me, aside from a couple notes.
There was a problem hiding this comment.
b2a6275 to
1c2a973
Compare
There was a problem hiding this comment.
are the changes here correct? It seems like a bunch of constants are re-defined here now.
I think this will likely need to be rebased after #3094 shifted around a lot of these imports, but the re-definition of constants seems a separate issue so just wanted to flag that
| # The number of field elements in an asset. | ||
| const ASSET_SIZE=8 | ||
|
|
||
| # The size of the memory segment allocated to each note. | ||
| const NOTE_MEM_SIZE=1024 | ||
|
|
||
| # The pointer at which the output vault root starts. | ||
| const OUTPUT_VAULT_ROOT_PTR=8 | ||
|
|
||
| # The offset of the output note section. | ||
| const OUTPUT_NOTE_SECTION_OFFSET=16777216 | ||
|
|
There was a problem hiding this comment.
seems that constants have been re-defined across more than just one file
| self.mast_store.insert(TransactionKernel::library().mast_forest().clone()); | ||
| self.mast_store.insert(program.mast_forest().clone()); |
There was a problem hiding this comment.
IIUC, this used to load the debug info in the previous VM versions, and will now fall back to LoadedMastForest::new(...) which no longer contains debug info
There was a problem hiding this comment.
and similarly in other users of TransactionMastStore::insert
| /// Registers all procedures of the provided [Package] with this store. | ||
| fn insert_package(&self, package: &Package) { | ||
| self.insert_loaded(loaded_mast_forest_from_package(package)); | ||
| } |
There was a problem hiding this comment.
The key function here seems to loaded_mast_forest_from_package which adds the debug info.
It might be worth marking this explicitly in this fn's docs
| /// Registers all procedures of the provided [MastForest] with this store. | ||
| pub fn insert(&self, mast_forest: Arc<MastForest>) { | ||
| self.insert_loaded(LoadedMastForest::new(mast_forest)); | ||
| } |
There was a problem hiding this comment.
similarly here (and IIUC) this fn will NOT add debug info, whereas previously it would have by default, because the debug info lived on the MastForest object
| #[must_use] | ||
| pub fn with_debug_mode(mut self) -> Self { | ||
| self.exec_options = self.exec_options.with_debugging(true); | ||
| pub fn with_debug_mode(self) -> Self { | ||
| self | ||
| } |
This updates Miden VM to v0.24, Miden Crypto to v0.27, and rand to v0.10.
The VM upgrade moved package debug info out of MastForest. This PR keeps that debug info attached through scripts, account code, and MAST forest stores by carrying
PackageDebugInfoinLoadedMastForest.This also updates MASM imports and build helpers for the new assembly package API.
Closes #3064